function [ Rez_Im ,I_highpassed] = highpassFilt_hw3( I,maskM,histMin,histMax )
%UNTITLED Summary of this function goes here
%   Detailed explanation goes here
if(numel(maskM) == 1)
    mask=ones(maskM) / (maskM * maskM);
else
    mask=maskM;
end
I=double(I);

%low pass filter
blurrImage=imfilter(I,mask); %lowPass(I,mask);

%histogram shrink
Ilp_shrink=image_hist_adjust(blurrImage ,0,255,histMin,histMax);

%get filtered
I_highpassed=(I-Ilp_shrink);

%subtract
tmp = I + I_highpassed;

I_highpassed=uint8(I-Ilp_shrink);

%enhance image
Rez_Im=image_hist_adjust(tmp ,histMin,histMax,0,255);
Rez_Im=uint8(abs(Rez_Im));
end


function [Im]=image_hist_adjust(I,a,b,A,B)
Im= ((I-a) / (b-a)) * (B-A)+A;
end